/*
 * GeraSenha.java
 *
 * Created on 23 de Novembro de 2007, 19:29
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package br.cesupa.cabcc.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class GeraSenha {
    
    public static String criptografaSenha(String senha) {
        MessageDigest md;
        String senhaMD5 = null;
        try {
            md = MessageDigest.getInstance("SHA-1");
            
            md.update(senha.getBytes());
            BigInteger hash = new BigInteger( 1, md.digest() );
            senhaMD5 = hash.toString( 16 );
        } catch (NoSuchAlgorithmException ex) {
            ex.printStackTrace();
        }
        
        return senhaMD5;
    }
}